package com.ruix.app.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;

import com.ruix.app.R;
import com.ruix.app.adapter.superadapter.SuperAdapter;
import com.ruix.app.adapter.superadapter.internal.SuperViewHolder;
import com.ruix.app.manager.UserManager;
import com.ruix.app.model.Notice;
import com.ruix.app.model.PostsCard;
import com.ruix.app.util.RoleUtil;
import com.ruix.app.widget.PostsTagsContentView;

import java.util.ArrayList;

/**
 * Created by hadexs on 2017/4/21.
 */

public class PostTagsAdaptar extends SuperAdapter<PostsCard> {

    private PostTagsAdaptarLisentler lisentler;

    public PostTagsAdaptar(Context context) {
        super(context, R.layout.item_post_tag);
    }

    @Override
    public void onBind(SuperViewHolder holder, int viewType, final int position, final PostsCard item) {

        if (item != null) {
            PostsTagsContentView view =  holder.getView(R.id.tv_post_content);
            String words;
            ArrayList ablums =  item.getAlbum();
            if (ablums != null && ablums.size() > 0){
                words = item.getWords() + " [图片]";
            } else  {
                words =  item.getWords();
            }
            view.setContentText(words);
            holder.setText(R.id.tv_username, item.getUserName());
            holder.setText(R.id.tv_create_time, item.getCreatedTimeDisplay());
            holder.setOnClickListener(R.id.rl_post_root_view, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (lisentler != null){
                        lisentler.onItemClick(position);
                    }
                }
            });
        }
    }


    public PostTagsAdaptarLisentler getLisentler() {
        return lisentler;
    }

    public void setLisentler(PostTagsAdaptarLisentler lisentler) {
        this.lisentler = lisentler;
    }

    public interface  PostTagsAdaptarLisentler{
       void onItemClick(int position);
    }



}
